//
//  CYMainViewCotroller.swift
//  WeiBo
//
//  Created by Mr_J on 16/3/2.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

class CYMainViewCotroller: UITabBarController {
    
   
    
    
    

    override func viewDidLoad() {
        super.viewDidLoad()
        
            
        
        
    
        // Do any additional setup after loading the view.
        
        addChildViewController(CYHomeTableViewController(), imageNamed: "tabbar_home", title:"主页")
        addChildViewController(CYMessageTableViewController(), imageNamed: "tabbar_message_center", title:"消息")
        addChildViewController(CYDiscoverTableViewController(), imageNamed: "tabbar_discover", title:"发现")
        addChildViewController(CYProfileTableViewController(), imageNamed: "tabbar_profile", title:"我")
        
        
        
    }

  
    private func addChildViewController(childController: UIViewController,imageNamed: String , title: String) {
        
        childController.title = title
        
        childController.tabBarItem.image = UIImage(named: imageNamed)?.imageWithRenderingMode(.AlwaysOriginal)
        
        childController.tabBarItem.selectedImage = UIImage(named: "\(imageNamed)_selected")?.imageWithRenderingMode(.AlwaysOriginal)
        
        let att = [NSForegroundColorAttributeName:UIColor.orangeColor()]
        
        childController.tabBarItem.setTitleTextAttributes(att, forState: UIControlState.Selected)
        
        addChildViewController(CYNavigationController(rootViewController: childController))
    }

    
    

}
